<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="合同编号">
              <j-input placeholder="请输入合同编号" v-model="queryParam.contractNum"></j-input>
            </a-form-item>
          </a-col>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="资产名称">
              <j-search-select-tag placeholder="请选择资产名称" :async="true" :is-like="true" v-model="queryParam.assetId"
                                   dict="zcgl_asset_info,asset_name,id" /><!--,status>1-->
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="管理人员">
              <j-search-select-tag placeholder="请选管理人员" :async="true" v-model="queryParam.managerId"
                                   dict="sys_user,realname,id" />
            </a-form-item>
          </a-col>

          <template v-if="toggleSearchStatus">

            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="管区">
                <j-dict-select-tag placeholder="请选管区" :async="true" v-model="queryParam.regional"
                                   dictCode="zcgl_regional" />
              </a-form-item>
            </a-col>

            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="资产明细">
                <j-search-select-tag placeholder="请选择资产明细" :is-like="true" :async="true"
                                     v-model="queryParam.assetSubIds"
                                     dict="zcgl_asset_info_sub,room_name,id" />
              </a-form-item>
            </a-col>

            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="客户名称">
                <j-search-select-tag placeholder="请选择客户名称" v-model="queryParam.customerId"
                                     :async="true" dict="zcgl_customer_info,name,id" />
              </a-form-item>
            </a-col>
            <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
            <!--              <a-form-item label="合同状态">-->
            <!--                <j-dict-select-tag placeholder="请选择合同状态" v-model="queryParam.status" dictCode="zcgl_contract_status"/>-->
            <!--              </a-form-item>-->
            <!--            </a-col>-->
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="合同状态">
                <j-dict-select-tag placeholder="请选择合同状态" v-model="queryParam.status" dictCode="zcgl_contract_status" />
              </a-form-item>
            </a-col>
            <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
            <!--              <a-form-item label="商户名称">-->
            <!--                <a-input placeholder="请输入商户名称" v-model="queryParam.merchantName"></a-input>-->
            <!--              </a-form-item>-->
            <!--            </a-col>-->
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="租金支付方式">
                <j-dict-select-tag placeholder="请选择租金支付方式" v-model="queryParam.modeOfPayment"
                                   dictCode="zcgl_lease_contract_paymenttype" />
              </a-form-item>
            </a-col>
            <a-col :xl="10" :lg="11" :md="12" :sm="24">
              <a-form-item label="起租时间">
                <j-date placeholder="请选择开始日期" class="query-group-cust"
                        v-model="queryParam.rentStartTime_begin"></j-date>
                <span class="query-group-split-cust"></span>
                <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.rentStartTime_end"></j-date>
              </a-form-item>
            </a-col>
            <a-col :xl="10" :lg="11" :md="12" :sm="24">
              <a-form-item label="到租时间">
                <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.rentEndTime_begin"></j-date>
                <span class="query-group-split-cust"></span>
                <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.rentEndTime_end"></j-date>
              </a-form-item>
            </a-col>

            <a-col :xl="6" :lg="7" :md="8" :sm="24" v-is-group>
              <a-form-item label="所属公司">
                <j-company-select-tag placeholder="请选择所属公司" v-model="queryParam.companyId" />
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button v-has="'leaseContractInfo:add'" @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button v-has="'leaseContractInfo:export'" type="primary" icon="download" @click="handleExportXls('合同信息')">导出
      </a-button>
      <a-upload v-has="'leaseContractInfo:import'" name="file" :showUploadList="false" :multiple="false"
                :headers="tokenHeader" :action="importExcelUrl"
                @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-button v-has="'leaseContractInfo:temp'" type="primary" icon="download"
                @click="handleExportXlsTemplate('合同信息模板')">模板下载
      </a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
<!--          <a-menu-item v-has="'leaseContractInfo:delete'" key="1" @click="batchDel">-->
<!--            <a-icon type="delete" />-->
<!--            删除-->
<!--          </a-menu-item>-->
          <a-menu-item v-has="'leaseContractInfo:batchTakeEffect'" key="1" @click="batchTakeEffect">
            批量生效
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down" />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
      <!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{-->
      <!--        selectedRowKeys.length }}</a>项-->
      <!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
      <!--      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :scroll="{ x: 2500 , y: screenHeight}"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-wrap"
        @change="handleTableChange">
        <!--        class="j-table-force-nowrap"-->
        <!--        class="j-table-force-nowrap"-->
        <!--        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"-->

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <div slot="filterDropdown">
          <a-card>
            <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
              <a-row>
                <template v-for="(item,index) in defColumns">
                  <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                    <a-col :span="8">
                      <a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox>
                    </a-col>
                  </template>
                </template>
              </a-row>
            </a-checkbox-group>
          </a-card>
        </div>
        <a-icon slot="filterIcon" type='setting' :style="{ fontSize:'16px',color:  '#108ee9' }" />

        <span slot="action" slot-scope="text, record">

          <a v-has="'leaseContractInfo:look'" @click="handleDetail(record)">查看</a>


          <template v-if="record.status == 10 || record.status == '' || record.status == null">

          <a-divider v-has="'leaseContractInfo:look'" type="vertical" />

            <template v-if="isApproval == 1">
              <a v-if="record.processStatus == 2" v-has="'leaseContractInfo:takeEffect'"
                 @click="leaseContractOperation('生效', record, 4)">生效</a>
              <a v-else v-has="'leaseContractInfo:takeEffect'" @click="processCreate(record, '生效审批', 0)">生效审批</a>
              <a-divider v-has="'leaseContractInfo:takeEffect'" type="vertical" />
            </template>
            <template v-else>
              <a v-has="'leaseContractInfo:takeEffect'" @click="leaseContractOperation('生效', record, 4)">生效</a>
              <a-divider type="vertical" />
            </template>


            <a-dropdown>
              <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
              <a-menu slot="overlay">
                <a-menu-item v-if="isApproval != 1 || record.processStatus == -1" v-has="'leaseContractInfo:edit'">
                <a @click="handleEditA(record, 1)">编辑</a>
                </a-menu-item>
                <a-menu-item v-has="'leaseContractInfo:print'">
                  <a @click="handlePrint(record,1)">合同打印预览</a>
                </a-menu-item>
                <a-menu-item v-if="isApproval != 1 || record.processStatus == -1" v-has="'leaseContractInfo:delete'">
                  <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a>删除</a>
                  </a-popconfirm>
                </a-menu-item>
              </a-menu>
            </a-dropdown>

          </template>

          <span v-else-if="record.status == 20 || record.status == 30">

          <a-divider v-has="'leaseContractInfo:look'" type="vertical" />

            <a-dropdown>
              <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
              <a-menu slot="overlay">
                <a-menu-item v-has="'leaseContractInfo:print'">
                  <a @click="handlePrint(record,2)">合同打印</a>
                </a-menu-item>

                <template v-if="isApproval == 1">
<!--                  <a-menu-item v-has="'leaseContractInfo:renew'">-->
<!--                    <a @click="handleRenew(record)">续签</a>-->
<!--                  </a-menu-item>-->
                  <a-menu-item v-has="'leaseContractInfo:edit'">
                      <a v-if="record.processStatus == 2" @click="handleEditA(record, 2)">变更</a>
                      <a v-else @click="processCreate( record, '变更',1)">变更审批</a>
                  </a-menu-item>
                  <a-menu-item v-has="'leaseContractInfo:renew'">
<!--                      <a v-if="record.processStatus == 2" @click="leaseContractOperation('续签', record, 1)">续签</a>-->
                      <a @click="processCreate(record, '续签审批', 2)">续签审批</a>
                  </a-menu-item>
                  <a-menu-item v-has="'leaseContractInfo:termination'">
                      <a v-if="record.processStatus == 2" @click="leaseContractOperation('终止', record, 3)">终止</a>
                      <a v-else @click="processCreate(record, '终止审批', 3)">终止审批</a>
                  </a-menu-item>
                </template>
                <template v-else>
                  <a-menu-item v-has="'leaseContractInfo:edit'">
                      <a @click="handleEditA(record, 2)">变更</a>
                  </a-menu-item>
<!--                  <a-menu-item v-has="'leaseContractInfo:renew'">-->
<!--                      <a @click="leaseContractOperation('续签', record, 1)">续签</a>-->
<!--                  </a-menu-item>-->
                  <a-menu-item v-has="'leaseContractInfo:termination'">
                      <a @click="leaseContractOperation('终止', record, 3)">终止</a>
                  </a-menu-item>
                </template>
                <!--                <a-menu-item v-has="'leaseContractInfo:surrender'">-->
                <!--                  <a @click="leaseContractOperation('退租', record, 2)">退租</a>-->
                <!--                </a-menu-item>-->
                <a-menu-item v-has="'leaseContractInfo:terminate'">
                  <a @click="leaseContractOperation('结束', record, 5)">结束</a>
                </a-menu-item>
              </a-menu>
            </a-dropdown>
            <!--<a @click="handleRenew(record)">续签</a>
            <a-divider type="vertical"/>

            <a @click="handleTermination(record)">终止</a>
            <a-divider type="vertical"/>

            <a @click="handleSurrender(record)">退租</a>-->
          </span>
          <div v-else>

          </div>

        </span>

      </a-table>
    </div>

    <leaseContractInfo-modal ref="modalForm" @ok="modalFormOk"></leaseContractInfo-modal>
    <leaseContractOperation-modal ref="leaseContractOperationModal"
                                  @ok="leaseContractOperationModalOk"></leaseContractOperation-modal>
    <leaseContractPrint-modal ref="leaseContractPrintModal" @ok="leaseContractPrintModalOk"></leaseContractPrint-modal>
    <leaseContractSelectTemplate-modal ref="leaseContractSelectTemplateModal"
                                       @ok="leaseContractSelectTemplateModalOk"></leaseContractSelectTemplate-modal>


    <!--流程表单-->
    <a-modal :title="lcModa.title" v-model="lcModa.visible" :footer="null" :maskClosable="false" width="80%">
      <component :disabled="lcModa.disabled" v-if="lcModa.visible" :is="lcModa.formComponent"
                 :processData="lcModa.processData" :isNew="lcModa.isNew"
                 @afterSubmit="processFormOk" @close="lcModa.visible=false, lcModa.disabled = false"></component>
    </a-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import LeaseContractInfoModal from './modules/LeaseContractInfoModal'
import LeaseContractOperationModal from './modules/LeaseContractOperationModal'
import LeaseContractPrintModal from './modules/LeaseContractPrintModal'
import LeaseContractSelectTemplateModal from './modules/LeaseContractSelectTemplateModal'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
import JDate from '@/components/jeecg/JDate.vue'
import { activitiMixin } from '@views/activiti/mixins/activitiMixin'
import JSearchSelectTag from '@comp/dict/JSearchSelectTag'
import JInput from '@comp/jeecg/JInput'
import Vue from 'vue'
import JCompanySelectTag from '@comp/jeecg/JCompanySelectTag'
import {postAction,getAction} from '@/api/manage'

export default {
  name: 'LeaseContractInfoList',
  mixins: [activitiMixin, JeecgListMixin, mixinDevice],
  components: {
    JInput,
    JSearchSelectTag,
    JDictSelectTag,
    JDate,
    LeaseContractPrintModal,
    LeaseContractOperationModal,
    LeaseContractSelectTemplateModal,
    JCompanySelectTag,
    LeaseContractInfoModal
  },
  data () {
    return {
      description: '合同信息管理页面',

      confirmLoading: false,
      // 表头
      columns: [],
      //列设置
      settingColumns: [],
      //列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          fixed: 'left',
          customRender: (text, record, index) =>
            `${(this.ipagination.current - 1) * this.ipagination.pageSize + index + 1}`
        },
        {
          title: '合同编号',
          align: 'center',
          // fixed:"left",
          // width: 200,
          // ellipsis: true,
          dataIndex: 'contractNum'
        },
        // {
        //   title: '合同类型',
        //   align: 'center',
        //   // fixed:"left",
        //   // width: 200,
        //   // ellipsis: true,
        //   dataIndex: 'type_dictText'
        // },
        {
          title: '客户名称',
          align: 'center',
          // fixed:"left",
          // width: 200,
          dataIndex: 'customerId_dictText'
        },
        {
          title: '余额',
          align: 'center',
          // fixed:"left",
          // width: 200,
          dataIndex: 'totalBalance',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            let b = text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
            return b
          }
        },
        {
          title: '资产名称',
          align: 'center',
          // fixed:"left",
          // width: 200,
          dataIndex: 'assetId_dictText'
        },
        // {
        //   title: '资产明细',
        //   align: 'center',
        //   // fixed:"left",
        //   // width: 200,
        //   dataIndex: 'assetSubIds_dictText'
        // },
        // {
        //   title: '打印模版',
        //   align: 'center',
        //   dataIndex: 'printTemplateId_dictText'
        // },
        {
          title: '合同状态',
          align: 'center',
          dataIndex: 'status_dictText'
        },
        {
          title: '经营业态',
          align: 'center',
          dataIndex: 'manageStatus'
        },
        {
          title: '出租方',
          align: 'center',
          dataIndex: 'rentCompanyId_dictText'
        },
        // {
        //   title: '商户名称',
        //   align: 'center',
        //   dataIndex: 'merchantName'
        // },
        {
          title: '出租面积',
          align: 'center',
          dataIndex: 'rentableArea'
        },
        {
          title: '租金单价（元）',
          align: 'center',
          dataIndex: 'rentPrice',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '计费方式',
          align: 'center',
          dataIndex: 'chargeType_dictText'
        },
        // {
        //   title: '合同模版',
        //   align: 'center',
        //   dataIndex: 'contractTemplate_dictText',
        // },
        {
          title: '月租金（元）',
          align: 'center',
          dataIndex: 'monthlyRent',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '保证金（元）',
          align: 'center',
          dataIndex: 'cashDeposit',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '违约金（元）',
          align: 'center',
          dataIndex: 'liquidatedDamages',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '合同租金浮动比例',
          align: 'center',
          dataIndex: 'contractChangeRatio',
          customRender: function (text) {
            return !text ? '0.00' : text.toFixed(4)
          }
        },
        {
          title: '租金支付方式',
          align: 'center',
          dataIndex: 'modeOfPayment_dictText'
        },
        {
          title: '起租时间',
          align: 'center',
          dataIndex: 'rentStartTime',
          customRender: function (text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '到租时间',
          align: 'center',
          dataIndex: 'rentEndTime',
          customRender: function (text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '免租开始日期',
          align: 'center',
          dataIndex: 'rentHolidayStart'
        },
        {
          title: '免租结束日期',
          align: 'center',
          dataIndex: 'rentHolidayEnd'
        },
        {
          title: '合同期限',
          align: 'center',
          dataIndex: 'contractPeriod'
        },
        {
          title: '签约日期',
          align: 'center',
          dataIndex: 'signingDate'
        },
        // {
        //   title: '租赁期限',
        //   align: 'center',
        //   dataIndex: 'termOfLease'
        // },
        // {
        //   title: '备注',
        //   align: 'center',
        //   dataIndex: 'remark',
        // },
        {
          title: '附件',
          align: 'center',
          dataIndex: 'accessory',
          scopedSlots: { customRender: 'fileSlot' }
        },
        {
          title: '创建日期',
          align: 'center',
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 200,
          // scopedSlots: { customRender: 'action' },
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      url: {
        list: '/zcgl/leaseContractInfo/list',
        delete: '/zcgl/leaseContractInfo/delete',
        deleteBatch: '/zcgl/leaseContractInfo/deleteBatch',
        exportXlsUrl: '/zcgl/leaseContractInfo/exportXls',
        importExcelUrl: 'zcgl/leaseContractInfo/importExcel',
        exportXlsTemplate: 'zcgl/leaseContractInfo/exportXlsTemplate',
        takeEffectApproval: 'zcgl/leaseContractInfo/takeEffectApproval',
        batchTakeEffect:"zcgl/leaseContractInfo/batchTakeEffect"
      },
      dictOptions: {}
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    initDictConfig () {
      this.initColumns()
      this.addColumns()
    },

    //批量生效
    batchTakeEffect(){

      if (!this.url.batchTakeEffect) {
        this.$message.error('请设置url.batchTakeEffect属性!')
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        var ids = ''
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ','
        }
        var that = this
        this.$confirm({
          title: '确认生效',
          content: '是否生效选中数据?',
          onOk: function () {
            that.loading = true
            getAction(that.url.batchTakeEffect, {ids:ids}).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.loadData()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.loading = false
            })
          }
        })
      }
    },


    // handleTakeEffect (re) {
    //   this.$refs.leaseContractOperationModal.show('生效', re, 4)
    // },

    // handleTakeEffect (id) {
    //   var that = this
    //   postTakeEffect({ id: id }).then((res) => {
    //     if (res.success) {
    //       this.$message.success(res.message)
    //       that.loadData()
    //     } else {
    //       this.$message.warning(res.message)
    //     }
    //   }).finally(() => {
    //     // this.confirmLoading = false
    //     // this.close()
    //   })
    // },
    //续签
    // handleRenew (re) {
    //   this.$refs.leaseContractOperationModal.show('续约', re, 1)
    // },
    //操作后返回
    leaseContractOperationModalOk () {
      this.loadData()
    },
    leaseContractPrintModalOk () {
      // this.loadData()
    },
    leaseContractSelectTemplateModalOk (re, type) {
      this.$refs.leaseContractPrintModal.show(re, type)
      this.loadData()
    },
    handleEditA: function (record, type) {
      this.$refs.modalForm.editA(record, type)
      this.$refs.modalForm.title = type == 1 ? '编辑' : "变更"
      this.$refs.modalForm.disableSubmit = false
    },
    leaseContractOperation (title, re, type) {
      this.$refs.leaseContractOperationModal.show(title, re, type)
    },
    // //退租
    // handleSurrender (re) {
    //   this.$refs.leaseContractOperationModal.show('退租', re, 2)
    // },
    // //终止
    // handleTermination (re) {
    //   this.$refs.leaseContractOperationModal.show('终止合同', re, 3)
    // },
    //合同打印
    handlePrint (re, type) {
      // this.$refs.leaseContractPrintModal.show(re, type)
      if (re.printTemplateId) {
        this.$refs.leaseContractPrintModal.show(re, type)
      } else {
        this.$refs.leaseContractSelectTemplateModal.show(re, type)
      }
    },
    processCreate (r, title, type) {
      // this.postParamsAction(this.url.takeEffectApproval, { id: r.id }).then((res) => {
      //   if (res.success) {
      let routeName = '@/views/activiti/form/LeaseContractTakeEffect'
      if (type == 1) {
        routeName = '@/views/activiti/form/LeaseContractModify'
      } else if (type == 2) {
        routeName = '@/views/activiti/form/LeaseContractRenew'
      } else if (type == 3) {
        routeName = '@/views/activiti/form/LeaseContractTermination'
      }
      let tableData = {
        routeName: routeName,
        tableName: 'zcgl_lease_contract_info',
        tableId: r.id
      }
      this.processCreateCom(tableData, '发起合同' + title + '流程', r.processStatus)
      //   } else {
      //     this.$message.warning(res.message)
      //   }
      // }).finally(() => {
      //   // this.confirmLoading = false
      // })
    },
    //列设置更改事件
    onColSettingsChange (checkedValues) {
      // let key = this.$route.name + ':colsettings:' + this.isGroup
      let key = this.$route.name + ':colsettings'
      Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
      this.settingColumns = checkedValues
      const cols = this.defColumns.filter(item => {
        if (item.key == 'rowIndex' || item.dataIndex == 'action') {
          return true
        }
        if (this.settingColumns.includes(item.dataIndex)) {
          return true
        }
        return false
      })
      this.columns = cols
    },
    initColumns () {
      //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
      // this.defColumns = colAuthFilter(this.defColumns,'testdemo:');

      let key = this.$route.name + ':colsettings'
      let colSettings = Vue.ls.get(key)
      if (colSettings == null || colSettings == undefined) {
        let allSettingColumns = []
        this.defColumns.forEach(function (item, i, array) {
          allSettingColumns.push(item.dataIndex)
        })
        this.settingColumns = allSettingColumns
        this.columns = this.defColumns
      } else {
        this.settingColumns = colSettings
        const cols = this.defColumns.filter(item => {
          if (item.key == 'rowIndex' || item.dataIndex == 'action') {
            return true
          }
          if (colSettings.includes(item.dataIndex)) {
            return true
          }
          return false
        })
        this.columns = cols
      }
    }

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>